using System;

namespace SharpMud.Net
{
    /// <summary>
    /// 
    /// </summary>
	public interface IDataPacket
	{
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
		byte[] ToByteArray();
	}

    /// <summary>
    /// 
    /// </summary>
	public class DataPacket
	{
        /// <summary>
        /// 
        /// </summary>
		private byte[] _Contents;

		/// <summary>
		/// 
		/// </summary>
        public DataPacket()
			:this(new byte[] {})
		{
		}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="contents"></param>
		public DataPacket(byte[] contents)
		{
			_Contents = contents;
		}

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
		public byte[] GetContents()
		{
			return _Contents;
		}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
		public void SetContents(byte[] value)
		{
			if(value==null) throw new ArgumentNullException("value");
			_Contents = value;
		}
		
		#region IDataPacket Members
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
		public byte[] ToByteArray()
		{
			return GetContents();
		}

		#endregion
	}
}
